<!DOCTYPE html>
<html>
<head>
<Title>TBA Activity Registration || Admin Page</Title>
	<!--a statisztika kirajzolasahoz szukseges libraryk-->
		<!-- css3 formak amelyek a design es lathatosagert felelosek-->
	<link href="Design.css" rel="stylesheet" type="text/css">
	<link rel="stylesheet" href="css/stat.css" type="text/css" media="screen" />
	<link href="style.css" rel="stylesheet" type="text/css">
	<script src="libraries/RGraph.common.core.js" ></script>
    <script src="libraries/RGraph.common.dynamic.js" ></script>
    <script src="libraries/RGraph.common.tooltips.js" ></script>
    <script src="libraries/RGraph.common.effects.js" ></script>
	<script src="libraries/RGraph.common.key.js" ></script>
    <script src="libraries/RGraph.bar.js" ></script>
    <script src="libraries/RGraph.line.js" ></script>
    <script src="libraries/jquery.min.js" ></script>
	<script src="libraries/RGraph.common.tooltips.js" ></script>
    <script src="libraries/RGraph.hbar.js" ></script>
		<script type="text/javascript">
		<!--adatbazisbol atvesszunk egyes listakat a statisztika kirajzolasahoz, es a valaszthato listahoz-->
			var userlist = [<?php include "classES.php"; $pclass = new users; $pclass->getuserlistdb($tmp1,$tmp2,$db,$un);echo "$tmp2";?>];
			var userIDlist = [<?php echo "$tmp1";?>];
			function populateList() {
				var proLen=userlist.length;
				for(var i=0; i<proLen; i++){<!--valaszthato lista feltoltesehez szukseges fuggveny-->
					document.userform.user.options[i]=new Option(userlist[i], userIDlist[i]);
				}
			}
			function changeFunc() {<!--ha lett valtoztatva a valaszthato lista atiranyitodik a masik valasztott statisztikajara-->
				var selectBox = document.getElementById("selectBox");		
				var selectedValue = selectBox.options[selectBox.selectedIndex].value;
				window.location.href = 'people.php?aid='+selectedValue;
			}
		</script>
	</head>
	<body style="background-color:#69F;">
	<br><div id="title" style="background-color:#69F;">Users</div><br>
		<div id="subtitle">
		<!--lista a nevekkel akiket valasztva kilistazodik a hozzajuk tartozo statisztika diagram-->
			<p><form name="userform">
					Change User:
					<select name="user" id="selectBox" onchange="changeFunc();">
					</select><br>
			</form></p>
		</div>
			<table id="manager">
		<td id="managerbuttons" style="vertical-align:text-top;">
			<!-- admin felulet funkcioihoz gombok amelyekhez atugorhat -->
			<!-- projekt sttaisztikakt kirajzolasa-->
			<a href="projects.php?pid=1"><button id="button" width="50">Projects</button></a><br>
			<!-- alkalmazottakrol szolo statisztikak-->
			<a href="people.php?aid=Alt.Attila5"><button id="button" width="50">Employments</button></a><br>
			<!-- activityk kezelese-->
			<a href="activityedit.php"><button id="button" width="50">Edit Activities</button></a><br>
			<!-- altalanos statisztika-->
			<a href="stat.php"><button id="button" style="width:50"> Statistics </button></a><br>
			<!-- admin jog kiosztasa-->
			<a href="usersettings.php"><button id="button" style="width:50">Edit Users</button></a><br>
			<!-- kilepes az admin feluletrol -->
			<a href="BLL.php?logout="><button id="button" style="width:50">Logout</button></a><br>
		</td>
		<td  id="managerinfo ">
			<!-- html5 canvas funkciojanak a segitsegel kirajzoljuk az adott statisztikat-->
				<canvas id="cvs" width="800" height="400">[No canvas support]</canvas>
					<!-- a script amelynek segitsegevel kirajzoljuk az adott statisztikat -->
					<script>
						window.onload = function ()
						{
							<?php
								//kivesszuk a get metodussal az adott felhasznalo azonositojat, amelyre lekerjuk az ab-bol
								//a listat a dolgozott orakkal es napokkal
								$userid = wordwrap($_GET['aid']);
								//csatoljuk a projekt es activityhoursclass osztalyokat aktivitas es projektek lekerdezesere
								$tmpclass1 = new activityhours;
								$tmpclass = new projects;
								$tmpclass -> getprojectwithuserlistdb($userid,$projectlist,$projectid,$db1);
								$i=0;$workhourp="";$workdayp="";$workhour="";$workday="";
								while ($i<$db1){
									$tmpclass1 -> set_username($userid);
									$tmpclass1 -> set_projectid($projectid[$i]);
									$tmpclass1 -> getsumactivityhourdb($workhourp);
									//osszesitjuk az aktivitasi orajukat
									$workhour=$workhour."$workhourp";
									//dokumentalasi orakat
									$tmpclass1 -> getsumactivitydaydb($workdayp);
									$workday=$workday."$workdayp";
									$i++;
									if ($i<$db1){ $workhour=$workhour.","; $workday=$workday.",";}
								}
							?>
							<!--atadjuk sorba az adott aktivitasi orakat a valtozoknak az ab-bol-->
							var workhour = [<?php echo "$workhour";?>];
							var workday = [<?php echo "$workday";?>];
							var projectnamelist = [<?php echo "$projectlist"; ?>];
							var listLen=projectnamelist.length;
							var listmerge = [];
							<!--osszefuzzuk a ket listat majd elkeszitjuk a statisztika diagramot hozza-->
							for (var i=0;i<listLen;i++){
								listmerge[i] = new Array(2);
								listmerge[i][0]=workhour[i];
								listmerge[i][1]=workday[i];
							}
							var hbar = new RGraph.HBar('cvs', listmerge);
							//atadjuk az ezekhez tartozo neveket
							hbar.Set('labels', projectnamelist);
							hbar.Set('labels.above', true);
							//formazasi dolgok szinek, meretek meghatarozasa, keretek
							hbar.Set('colors', ['#00f','#0f0']);
							//egyes iranymutatok hogy mi mit jelol
							hbar.Set('key', ['Worked hour','Worked day']);
							hbar.Set('key.position.gutter.boxed', false);
							hbar.Set('key.position', 'gutter');
							hbar.Set('key.background', 'rgb(255,255,255)');
							//elhelyezkedesek beallitasa
							hbar.Set('hmargin', 165);
							hbar.Set('hmargin.grouped', 1);
							hbar.Set('gutter.left', 150);
							hbar.Set('gutter.bottom', 45);
							hbar.Set('background.grid.vlines', false);
							hbar.Set('background.grid.border', false);
							//effektel pedig megjeleniteni az adott statisztikat
							RGraph.Effects.HBar.Grow(hbar);
							populateList();
						}
					</script>
		<!-- lehetoseg van az adminisztratornak uj projekt hozzaadasahoz-->
      </td>
	</table>
	</div>
	</body>
</html>